package cn.kgc.kgcesproduct.controller;

import cn.kgc.kgcesproduct.pojo.Product;
import cn.kgc.kgcesproduct.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author geQiang
 * @version 1.0
 * @date 2019/4/14
 * @description cn.kgc.kgcesproduct.controller
 */
@RestController
public class ProductContoller {
    @Resource
    private ProductService productService;

    @RequestMapping("/addIndexAndSet")
    public void addIndexAndSet(
            @RequestParam(value = "index", defaultValue = "", required = false) String index) {
        productService.addIndexAndSet(index);
    }

    @RequestMapping("/addbatch")
    public void addbatch(@RequestParam(value = "index", defaultValue = "", required = false) String index) {
        productService.addDocumetBybulk(index);
    }

    @RequestMapping("/query")
    public List<Product> query(
            @RequestParam(value = "index", defaultValue = "", required = false) String index,
            @RequestParam(value = "range", defaultValue = "", required = false) String range,
            @RequestParam(value = "name", defaultValue = "", required = false) String name,
            @RequestParam(value = "start", defaultValue = "0", required = false) Double start,
            @RequestParam(value = "end", defaultValue = "0", required = false) Double end) {
        return productService.query(index, range, name, start, end);
    }


}
